#!/bin/bash

# 定义YAML文件内容
yaml_content="
id: top.openkylin.$1
runtime: top.openkylin.Platform
runtime-version: "2.0"
sdk: top.openkylin.Sdk
command: $1
finish-args:
  - --filesystem=xdg-run/dconf
  - --filesystem=~/.config/dconf:ro
  - --talk-name=ca.desrt.dconf
  - --env=DCONF_USER_CONFIG_DIR=.config/dconf
  - --env=GIO_EXTRA_MODULES=/app/lib/gio/modules
  - --share=ipc
  - --socket=x11
  - --socket=wayland
  - --socket=pulseaudio
  - --filesystem=/tmp:rw
  - --filesystem=xdg-pictures:rw
  - --filesystem=xdg-videos:rw
  - --filesystem=home:rw
  - --device=all
modules:
  - name: $1
    buildsystem: simple
    build-command: [
       dpkg-deb -R $1 tmp
       cp -r ./usr/* /app 
       rm 
    ]
    sources:
      - type: git
        url: https://gitee.com/openkylin/kylin-scanner.git
        commit: b52540b505e1b3719bf8f069f20b6c446d0fe7bb
      - type: patch
        patch: patch/0001-kylin-scanner-flatpak.patch
      - type: patch
        patch: patch/0002-kylin-scanner-add-appdata.patch

"

# 写入YAML文件
output_file="app_config.yml"

# 创建并写入文件
echo "$yaml_content" > "$output_file"

# 检查是否成功写入
if [ $? -eq 0 ]; then
  echo "YAML file '$output_file' created successfully."
else
  echo "Error creating YAML file."
fi
